{"ast":null,"code":"export const REQUIRED_FIELD = 'Обязательно для заполнения';\nconst reg = /\\.[a-zа-я]{1,10}$/i;\nexport const emailValidation = {\n  required: REQUIRED_FIELD,\n  validate: value => {\n    if (value.length < 4 || value.length > 128) {\n      return 'Эл. адрес должен быть от 4 до 128 символов';\n    }\n    if (!reg.test(value)) {\n      return 'Эл. адрес должен иметь тип: \"example@example.com\"';\n    }\n    return true;\n  }\n};\nexport const nicknameValidation = {\n  required: REQUIRED_FIELD,\n  validate: value => {\n    if (value.length < 2 || value.length > 30) {\n      return 'Псевдоним должен быть от 2 до 30 символов';\n    }\n    return true;\n  }\n};\nexport const nicknameChangeValidation = {\n  validate: value => {\n    if (value) {\n      if (value.length !== 0 && (value.length < 2 || value.length > 30)) {\n        return 'Псевдоним должен быть от 2 до 30 символов';\n      }\n    }\n    return true;\n  }\n};\nexport const firstNameChangeValidation = {\n  validate: value => {\n    if (value) {\n      if (value.length !== 0 && (value.length < 2 || value.length > 30)) {\n        return 'Имя должено быть от 2 до 30 символов';\n      }\n    }\n    return true;\n  }\n};\nexport const lastNameChangeValidation = {\n  validate: value => {\n    if (value) {\n      if (value.length !== 0 && (value.length < 2 || value.length > 30)) {\n        return 'Фамилия должена быть от 2 до 30 символов';\n      }\n    }\n    return true;\n  }\n};\nexport const passwordValidation = {\n  required: REQUIRED_FIELD,\n  validate: value => {\n    if (value.length < 8) {\n      return 'Пароль должен быть длиннее 8 символов';\n    }\n    return true;\n  }\n};\nexport const passwordChangeValidation = {\n  validate: value => {\n    if (value && value.length < 8) {\n      return 'Пароль должен быть длиннее 8 символов';\n    }\n    return true;\n  }\n};\nexport const confirmPassword = (firstValue, secondValue) => {\n  return {\n    required: REQUIRED_FIELD,\n    validate: () => {\n      if (firstValue !== secondValue) {\n        return 'Пароли должны совпадать';\n      }\n      return true;\n    }\n  };\n};\nexport const confirmChangePassword = (firstValue, secondValue) => {\n  if ((firstValue === null || firstValue === void 0 ? void 0 : firstValue.length) === 0 && (secondValue === null || secondValue === void 0 ? void 0 : secondValue.length) === 0) {\n    return false;\n  }\n  if (firstValue !== null && firstValue !== void 0 && firstValue.length || secondValue !== null && secondValue !== void 0 && secondValue.length) {\n    if (firstValue !== null && firstValue !== void 0 && firstValue.length && secondValue !== null && secondValue !== void 0 && secondValue.length) {\n      return {\n        required: REQUIRED_FIELD,\n        validate: () => {\n          if (firstValue !== secondValue) {\n            return 'Пароли должны совпадать';\n          }\n          return true;\n        }\n      };\n    } else if (firstValue !== null && firstValue !== void 0 && firstValue.length) {\n      return {\n        required: REQUIRED_FIELD,\n        validate: () => {\n          return 'Вы должны повторить пароль';\n        }\n      };\n    } else if (secondValue !== null && secondValue !== void 0 && secondValue.length) {\n      return {\n        required: REQUIRED_FIELD,\n        validate: () => {\n          return 'Вы сначала должны придумать пароль';\n        }\n      };\n    }\n  } else {\n    return true;\n  }\n};","map":{"version":3,"names":["REQUIRED_FIELD","reg","emailValidation","required","validate","value","length","test","nicknameValidation","nicknameChangeValidation","firstNameChangeValidation","lastNameChangeValidation","passwordValidation","passwordChangeValidation","confirmPassword","firstValue","secondValue","confirmChangePassword"],"sources":["/data/messenger.client/src/modules/validation.ts"],"sourcesContent":["export const REQUIRED_FIELD = 'Обязательно для заполнения';\n\nconst reg = /\\.[a-zа-я]{1,10}$/i;\n\nexport const emailValidation = {\n    required: REQUIRED_FIELD,\n    validate: (value: string) => {\n        if (value.length < 4 || value.length > 128) {\n            return 'Эл. адрес должен быть от 4 до 128 символов'\n        }\n\n        if (!reg.test(value)) {\n            return 'Эл. адрес должен иметь тип: \"example@example.com\"'\n        }\n\n        return true;\n    }\n};\n\nexport const nicknameValidation = {\n    required: REQUIRED_FIELD,\n    validate: (value: string) => {\n        if (value.length < 2 || value.length > 30) {\n            return 'Псевдоним должен быть от 2 до 30 символов'\n        }\n\n        return true;\n    }\n};\n\nexport const nicknameChangeValidation = {\n    validate: (value: string | null | undefined) => {\n        if (value) {\n            if (value.length !== 0 && (value.length < 2 || value.length > 30)) {\n                return 'Псевдоним должен быть от 2 до 30 символов'\n            }\n        }\n\n        return true;\n    }\n};\n\nexport const firstNameChangeValidation = {\n    validate: (value: string | null | undefined) => {\n        if (value) {\n            if (value.length !== 0 && (value.length < 2 || value.length > 30)) {\n                return 'Имя должено быть от 2 до 30 символов'\n            }\n        }\n\n        return true;\n    }\n};\n\nexport const lastNameChangeValidation = {\n    validate: (value: string | null | undefined) => {\n        if (value) {\n            if (value.length !== 0 && (value.length < 2 || value.length > 30)) {\n                return 'Фамилия должена быть от 2 до 30 символов'\n            }\n        }\n\n        return true;\n    }\n};\n\nexport const passwordValidation = {\n    required: REQUIRED_FIELD,\n    validate: (value: string) => {\n        if (value.length < 8) {\n            return 'Пароль должен быть длиннее 8 символов'\n        }\n\n        return true;\n    }\n};\n\nexport const passwordChangeValidation = {\n    validate: (value: string | null | undefined) => {\n        if (value && value.length < 8) {\n            return 'Пароль должен быть длиннее 8 символов'\n        }\n\n        return true;\n    }\n};\n\nexport const confirmPassword = (firstValue: string, secondValue: string) => {\n    return {\n        required: REQUIRED_FIELD,\n        validate: () => {\n            if (firstValue !== secondValue) {\n                return 'Пароли должны совпадать';\n            }\n        return true;\n    }\n    }\n};\n\nexport const confirmChangePassword = (firstValue: string | null | undefined, secondValue: string | null | undefined) => {\n    if (firstValue?.length! === 0 && secondValue?.length! === 0) {\n        return false;\n    }\n\n    if (firstValue?.length! || secondValue?.length!) {\n        if (firstValue?.length! && secondValue?.length!) {\n            return {\n                required: REQUIRED_FIELD,\n                validate: () => {\n                    if (firstValue !== secondValue) {\n                        return 'Пароли должны совпадать';\n                    }\n                    return true;\n                }\n            }\n        } else if (firstValue?.length!) {\n            return {\n                required: REQUIRED_FIELD,\n                validate: () => {\n                    return 'Вы должны повторить пароль';\n                }\n            }\n        } else if (secondValue?.length!) {\n            return {\n                required: REQUIRED_FIELD,\n                validate: () => {\n                    return 'Вы сначала должны придумать пароль';\n                }\n            }\n        }\n    }\n\n    else {\n        return true;\n    }\n};\n"],"mapp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